Skip to content

Docs: Added Solutions to Leetcode 621 #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2024

Conversation

shreyash3087
Copy link
Contributor

Related Issue

Closes #1379

Description

This PR adds the solution to leetcode problem 6621 - (Task Scheduler)

Type of PR

  • Bug fix
  • Feature enhancement
  • Documentation update
  • Security enhancement
  • Other (specify): _______________

Screenshots / Videos (if applicable)

screencapture-localhost-3000-dsa-solutions-lc-solutions-0600-0699-task-scheduler-2024-06-16-18_49_38

Checklist

  • I have performed a self-review of my code.
  • I have read and followed the Contribution Guidelines.
  • I have tested the changes thoroughly before submitting this pull request.
  • I have provided relevant issue numbers, screenshots, and videos after making the changes.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have followed the code style guidelines of this project.
  • I have checked for any existing open issues that my pull request may address.
  • I have ensured that my changes do not break any existing functionality.
  • Each contributor is allowed to create a maximum of 4 issues per day. This helps us manage and address issues efficiently.
  • I have read the resources for guidance listed below.
  • I have followed security best practices in my code changes.

Additional Context

N/A

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @shreyash3087! 🎉 Thank you for submitting your pull request to CodeHarborHub. We appreciate your contribution and enthusiasm! Our team will review it soon. If you have any questions or need further assistance, feel free to reach out. Thanks for contributing!

Copy link
Contributor

deepsource-io bot commented Jun 16, 2024

Here's the code health analysis summary for commits 6d71973..3042609. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@ajay-dhangar ajay-dhangar added documentation Improvements or additions to documentation GSSOC'24 GirlScript Summer of Code | Contributor level1 GirlScript Summer of Code | Contributor's Levels gssoc GirlScript Summer of Code | Contributor labels Jun 16, 2024
Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update code based on suggestions


### Constraints

- $1 <= tasks.length <= 10^4$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace $1 <= tasks.length <= 10^4$ to $1 \leq \text{tasks.length} \leq 10^4$


- $1 <= tasks.length <= 10^4$
- `tasks[i]` is an uppercase English letter.
- $0 <= n <= 100$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace $0 <= n <= 100$ to $0 \leq n \leq 100$


### Space Complexity: $O(1)$

> **Reason**: The space complexity is mainly determined by the frequency array and the priority queue. The frequency array has a constant size of 26, and the priority queue can have a maximum size of 26 when all distinct tasks are present. Therefore, the overall space complexity is O(1) or O(26), which is considered constant.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace O(1) to $O(1)$, O(26) to $O(26)$


> **Reason**: The space complexity is mainly determined by the frequency array and the priority queue. The frequency array has a constant size of 26, and the priority queue can have a maximum size of 26 when all distinct tasks are present. Therefore, the overall space complexity is O(1) or O(26), which is considered constant.

### Approach #2 Filling the Slots and Sorting
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace #2 to 2

>
> - In Python, the sort method sorts a list using the Timsort algorithm which is a combination of Merge Sort and Insertion Sort and has O(N) additional space.
> - In Java, Arrays.sort() is implemented using a variant of the Quick Sort algorithm which has a space complexity of O(log⁡N) for sorting two arrays.
> - In C++, the sort() function is implemented as a hybrid of Quick Sort, Heap Sort, and Insertion Sort, with a worse-case space complexity of O(log⁡N).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace v to $O(log⁡N)$

>
> Note that some extra space is used when we sort arrays in place. The space complexity of the sorting algorithm depends on the programming language.
>
> - In Python, the sort method sorts a list using the Timsort algorithm which is a combination of Merge Sort and Insertion Sort and has O(N) additional space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace O(N) to $O(N)$


> **Reason**: The frequency array has a size of 26.
>
> Note that some extra space is used when we sort arrays in place. The space complexity of the sorting algorithm depends on the programming language.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use note then try

:::note
// YOUR NOTES HERE
:::

Try this for best practice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shreyash3087
Copy link
Contributor Author

@ajay-dhangar Done

Copy link
Member

@ajay-dhangar ajay-dhangar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@ajay-dhangar ajay-dhangar merged commit 59d7389 into codeharborhub:main Jun 16, 2024
4 checks passed
@sanjay-kv sanjay-kv removed the level1 GirlScript Summer of Code | Contributor's Levels label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation gssoc GirlScript Summer of Code | Contributor GSSOC'24 GirlScript Summer of Code | Contributor
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Leetcode Problem 621 - (Task Scheduler-Medium)
3 participants